<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>评论</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            width: 500px;
            height: 500px;
            margin: 0 auto;
            background-color: pink;
        }

        textarea {
            width: 200px;
            height: 200px;
        }
    </style>
</head>

<body>
    <div>
        <textarea></textarea>
        <button>发布</button>
        <ul></ul>
    </div>
    <script>
        var btn = document.querySelector('button');
        var text = document.querySelector('textarea');
        var ul = document.querySelector('ul');
        btn.onclick = function () {
            if (text.value === '') {
                alert('请输入内容');
                return false;
            } else {
                var li = document.createElement('li');
                li.innerHTML = text.value;
                ul.insertBefore(li, ul.children[0]);
            }
        }
    </script>
</body>

</html>